#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;
vector<ll> v;
ll sum;
int main()
{
    ll n;
    scanf("%lld", &n);
    ll in = 0;
    v.push_back(0);
    for (ll i = 1; i <= n; i++)
    {
        scanf("%lld", &in);
        v.push_back(in);
    }
    sort(v.begin() + 1, v.end());
    ll Begin = 0, End = n;
    while (Begin < End)
    {
        sum += pow((v[End] - v[Begin]), 2);
        Begin++;
        sum += pow((v[Begin] - v[End]), 2);
        End--;
    }  
    /*
    for (ll i = 0; i <= n; i++)
        cout << v[i] << " ";
    */
    printf("%lld", sum);
    return 0;
}